package org.kele.sc2020.consumer.rpc.fallback;

import lombok.extern.slf4j.Slf4j;
import org.kele.sc2020.common.dto.KeleResult;
import org.kele.sc2020.consumer.rpc.ScProviderRPC;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ScProviderRPCfallback implements FallbackFactory<ScProviderRPC> {

    @Override
    public ScProviderRPC create(Throwable cause) {
        log.info("call sc-provider fallback 方法降级:", cause);


        return new ScProviderRPC() {
            @Override
            public String getFromProvider(String key) {
                return "调用失败";
            }

            @Override
            public KeleResult<Object> testRetry() {
                return KeleResult.rpcFail();
            }
        };
    }
}
